package com.share.domain.strategy.repository;

import com.share.domain.strategy.model.entity.StrategyAwardEntity;
import com.share.domain.strategy.model.entity.StrategyEntity;
import com.share.domain.strategy.model.entity.StrategyRuleEntity;
import com.share.domain.strategy.model.vo.RuleTreeVo;
import com.share.domain.strategy.model.vo.RuleWeightVo;
import com.share.domain.strategy.model.vo.StrategyAwardRuleModelVo;
import com.share.domain.strategy.model.vo.StrategyAwardStockKeyVo;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 策略的仓储接口
 */
public interface IStrategyRepository {

    List<StrategyAwardEntity> queryStrategyAwardList(Long strategyId);

    void storeStrategyAwardSearchRateTables(String key, int rateRange, Map<Integer, Integer> shuffleStrategyAwardSearchRateTables);



    Integer getRateRange(Long strategyId);
    Integer getRateRange(String key);

    Integer getStrategyAwardAssemble(String key, int rateKey);


    StrategyEntity queryStrategyEntitiesByStrategyId(Long strategyId);

    StrategyRuleEntity queryStrategyRule(Long strategyId, String ruleModel);

    String queryStrategyRuleValue(Long strategyId, Integer awardId, String ruleModel);
    String queryStrategyRuleValue(Long strategyId, String ruleModel);

    StrategyAwardRuleModelVo queryAwardRuleModel(Long strategyId, Integer awardId);

    RuleTreeVo queryRuleTreeVoByTreeId(String treeId);

    StrategyAwardRuleModelVo queryStrategyAwardRuleModelVo( Long strategyId, Integer awardId);

    void cacheStrategyAwardCount(String cacheKey, Integer awardCountSurplus);

    boolean subtractionAwardStock(String cacheKey, Date endDateTime);

    void awardStockConsumeSendQueue(StrategyAwardStockKeyVo strategyAwardStockKeyVo);

    StrategyAwardStockKeyVo takeQueueValue();

    void updateStrategyAwardStock(Long strategyId, Integer awardId);

    StrategyAwardEntity queryStrategyAwardEntity(Long strategyId, Integer awardId);

    Long queryStrategyIdByActivityId(Long activityId);

    int queryTodayUserRaffleCount(String userId, Long strategyId);

    Map<String, Integer> queryAwardRuleLockCount(String[] treeIds);

    Integer queryActivityAccountTotalUserCount(String userId, Long strategyId);

    List<RuleWeightVo> queryRuleWeight(Long strategyId);
}
